<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>校园网流量账号管理系统后台</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>

<body>
<form class="layui-form" id="record_edit" method="post" action="" style="padding: 20px 30px 0px 0px;">
  <div class="layui-form-item">
      <label class="layui-form-label">教工号</label>
      <div class="layui-input-block">
        <input type="text" name="username" id="username" placeholder="请输入教工号" autocomplete="off" class="layui-input" value="{$record.username}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">姓名</label>
      <div class="layui-input-block">
        <input type="text" name="real_name" id="real_name" placeholder="请输入姓名" autocomplete="off" class="layui-input" value="{$record.real_name}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">部门</label>
      <div class="layui-input-block">
        <input type="text" name="department" id="department" placeholder="请输入部门名称" autocomplete="off" class="layui-input" value="{$record.department}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">手机号</label>
      <div class="layui-input-block">
        <input type="text" name="tel" id="tel" placeholder="请输入手机号" autocomplete="off" class="layui-input" value="{$record.tel}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">邮箱</label>
      <div class="layui-input-block">
        <input type="text" name="email" id="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input" value="{$record.email}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">时长</label>
      <div class="layui-input-block">
        <select name="duration" id="duration">
          <option value=""></option>
          {volist name="$duration" id="vo" key="key"}
            <option value="{$key}"{if $record.duration == $key}selected{/if}>{$vo}</option>
          {/volist}
        </select>
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">账号</label>
      <div class="layui-input-block">
        <input type="text" name="account" id="account" placeholder="请输入账号" autocomplete="off" class="layui-input" value="{$record.account}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">密码</label>
      <div class="layui-input-block">
        <input type="text" name="password" id="password" placeholder="请输入密码" autocomplete="off" class="layui-input" value="{$record.password}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">过期日期</label>
      <div class="layui-input-block">
        <input type="text" name="expire_time" id="expire_time" placeholder="请选择过期日期" autocomplete="off" class="layui-input" value="{$record.expire_time}">
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">审核状态</label>
      <div class="layui-input-block">
        <select name="condition" id="condition" lay-verify="required">
          <option value=""></option>
          {volist name="$condition" id="vo" key="k"}
              <option value="{$key}"{if $record.condition == $vo}selected{/if}>{$vo}</option>
          {/volist}
        </select>
      </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn"  id="record_update">保存</button>
      <button class="layui-btn layui-btn-primary" id="closeIframe">取消</button>
    </div>
  </div>
</form>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="/static/html5shiv/html5shiv.min.js"></script>
<script src="/static/respond/respond.min.js"></script>
<![endif]-->
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(["laydate","form" ,'layer','jquery'], function(){
        var laydate = layui.laydate,form = layui.form,
            $ = layui.jquery,layer = layui.layer;
        //执行一个laydate实例
        laydate.render({
            elem: "#expire_time" //指定元素
            ,format: 'yyyy-MM-dd HH:mm'
        });
        form.render();
        var parentindex = parent.layer.getFrameIndex(window.name); //获取窗口索引
        $('#closeIframe').click(function(){
            parent.layer.close(parentindex);
        });
        $('#record_update').click(function(){
            console.log($('#record_edit').serialize())
            $.post("/index.php/record/update/{$record.id}", $('#record_edit').serialize(), function (res) {
                if (res.code == 200) {
                    parent.layer.msg(res.msg, {icon: 1});
                    window.location.href = "/index.php/record/{$record.id}";
                } else {
                    parent.layer.msg(res.msg, {icon: 2});
                }
                return false
            }, "json").fail(function (res) {
                var msg = res.responseJSON.msg, str = '';
                if (res.responseJSON.msg instanceof Object) {
                    for (var k in msg) {
                        str = str + msg[k] + '<br>';
                    }
                } else {
                    str = res.responseJSON.msg
                }
                parent.layer.msg(str, {icon: 0});
            })
        });
    });
</script>
</body>
</html>